package proxy

import java.lang.reflect.InvocationHandler
import java.lang.reflect.Method
import java.lang.reflect.Proxy

class DynamicProxy {


    class Handler : InvocationHandler {

        private fun proxyShopping() {
            PrintUtil.print("交给我你就别管了")
        }

        override fun invoke(proxy: Any?, method: Method?, args: Array<out Any>?): Any {
            return proxyShopping()
        }
    }

    fun getMarketProxy(): Shop {

        return Proxy.newProxyInstance(this.javaClass.classLoader, arrayOf(Shop::class.java), Handler()) as Shop
    }
}